import { Component, OnInit } from '@angular/core';
import { MessageService } from 'src/app/service/message.service';

@Component({
  selector: 'app-nav',
  templateUrl: './nav.component.html',
  styleUrls: ['./nav.component.css']
})
export class NavComponent implements OnInit {

  islogin: boolean
  user: any
  constructor(public messageService: MessageService) { }

  ngOnInit(): void {
    // localStorage.clear()
    this.user = JSON.parse(localStorage.getItem('userinfo'))
    console.log('NavComponent.this.user', this.user)
    if (this.user != null) {
      this.messageService.islogin = true
      this.messageService.usertype = this.user.type
    } else {
      this.messageService.islogin = false
      this.messageService.usertype = 0
    }
    // this.messageService.usertype = 1
    // this.messageService.islogin = true
    console.log('this.messageService.islogin', this.messageService.islogin)
    console.log('this.messageService.usertype', this.messageService.usertype)
  }

  logout(): void {
    localStorage.clear()
    window.location.assign('/')
  }

}
